﻿var NotificationImage = function(constructors) {

	var self = this;

	self.key = '';

	self.path = '';

	self.init = function() {
		var defaults = {
			key: '',
			path: ''
		};

		$.extend(defaults, constructors);

		self.key = defaults.key;
		self.path  = defaults.path;
	}

	self.init();

}

var Notification = function() {

	var self = this;

	self.Images = [
		new NotificationImage({
			key: 'info',
			path: app.baseUrl() + 'images/notification-information.PNG'
		}),
		new NotificationImage({
			key: 'question',
			path: app.baseUrl() + 'images/notification-question.PNG'
		}),
		new NotificationImage({
			key: 'warning',
			path: app.baseUrl() + 'images/notification-warning.PNG'
		}),
		new NotificationImage({
			key: 'error',
			path: app.baseUrl() + 'images/notification-error.PNG'
		})
	];

	self.getImagePath = function(key) {
		var path = '';

		$.each(self.Images, function(index) {
			var image = this;
			if (image.key.toLowerCase() == key.toLowerCase()) path = image.path;
		});

		return path;
	}

	self.shout = function(shoutOutSettings) {
		var defaultShoutOut = {
			title:  'Message',
			text: 'No message.',
			image: 'info'
		};

		$.extend(defaultShoutOut, shoutOutSettings);

		$.gritter.add({
			title: defaultShoutOut.title,
			text: defaultShoutOut.text,
			image: self.getImagePath(defaultShoutOut.image)
		});
	}

}

var notification = new Notification();